Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Unhandled promise rejection [Error: Got an invalid value for 'component' prop for the screen 'LocationType'. It must be a valid React Component.]

So I am trying to convert a string to an enum type and use it as a type in useState:

From

const [someType, setSomeType] = useState<"water", "air", "fire">("water")

This works fine but when I try to convert this to an enum type like

export enum SomeType {
  WATER,
  AIR,
  FIRE,
}
  const [someType, setSomeType] = useState<SomeType>(SomeType.WATER)

this throws and error

Unhandled promise rejection [Error: Got an invalid value for 'component' prop for the screen 'SomeType'. It must be a valid React Component.]

I have tried other ways too like

const [someType, setSomeType] = useState<SomeType.WATER | SomeType.AIR | SomeType.FIRE>(SomeType.WATER)

But the error is the same, Am I missing something here?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've not tried it myself so not sure if it'll work but you can try:

enum Example {}

...

const [type, setType] = useState({} as Example)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!